package homework;
import java.util.Random;
import java.util.Arrays;
public class homework5 {
    public static void main(String[] args) {

        //九九乘法表
        for (int num=1;num<=9;num++) {
            for (int i = 1; i <= num; i++) {
                System.out.print(i + "*" +num+"="+ i * num+"\t");
            }
            System.out.println();
        }

        //数组
        //1.声明
        int[] a = new int[5];
        double[] d = new double[5];
        boolean[] b = new boolean[5];
        char[] c = new char[5];
        //初始化
        int[] arr1 = new int[5];
        int[] arr2 = {1,2,3};
        int[] arr3 = new int[]{1,2,3};
        int[] arr4;
        arr4 = new int[]{1,2,3};
        //访问
        int[] a1 = new int[3];
        a1[0]=100;
        a1[1]=200;
        a1[2]=300;
        System.out.println("数组的长度："+a1.length);
        a1[a1.length-1]=400;//修改a1数组最后一个元素的值为400
        //遍历
        Random rand = new Random();
        int[] a2 = new int[5];
        for (int i=0;i<a2.length;i++){
            a2[i]=rand.nextInt(100);
            System.out.println(a2[i]);
        }
        //复制 可选择
        int[] a3={1,2,3,4,5};
        int[] a4 = new int[6];
        System.arraycopy(a3,0,a4,0,5);
        for (int i=0;i<a4.length;i++){
            System.out.println(a4[i]);
        }

        int[] a5={7,8,9,6,5};
        int[] a6 = Arrays.copyOf(a5,6);
        for (int i=0;i<a6.length;i++){
            System.out.println(a6[i]);
        }

        a6 = Arrays.copyOf(a6,7);
        for (int i=0;i<a6.length;i++){
            System.out.println(a6[i]);
        }

        //对数组进行升序排序
        int[] q1= new int[10];
        for (int i=0;i<q1.length;i++){
            q1[i]=(int)(Math.random()*100+1);
            System.out.println(q1[i]);
        }
        Arrays.sort(q1);
        System.out.println("排序后");
        for (int i=0;i<q1.length;i++){
            System.out.println(q1[i]);
        }
    }
}
